#include <stdio.h>

int func(int a, int b, int c)
{
    int t = a<b?a:b;
    return t<c?t:c;
}

int main()
{
    int i, n, *p1, *p2, *p3;
    int uglys[1500];
    uglys[0] = 1;
    p1 = p2 = p3 = uglys;
    for (i = 1; i<1500; i++){
        uglys[i] = func(*p1*2, *p2*3, *p3*5);
        while (*p1*2<=uglys[i]) ++p1;
        while (*p2*3<=uglys[i]) ++p2;
        while (*p3*5<=uglys[i]) ++p3;
    }
    while (~scanf("%d", &n))
        printf("%d\n", uglys[n-1]);
    return 0;
}
